import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:klfz_flutter/book/book_read/view.dart';
import 'package:klfz_flutter/config/RouteConfig.dart';
import 'package:klfz_flutter/model/novel_result.dart';

import 'logic.dart';

class BookDetailPage extends StatelessWidget {

  // final Novel? records;
  //
  // BookDetailPage({Key? key, this.records}) : super(key: key);

  final BookDetailLogic logic = Get.put(BookDetailLogic());

  @override
  Widget build(BuildContext context) {
    final novel = Get.arguments;
    if (novel is Novel) {
      logic.loadData(novel);
    }
    return Scaffold(
      appBar: AppBar(title: Text("详情"),),
      body: Container(
          child: GetBuilder<BookDetailLogic>(
            builder: (logic) {
              return ListView.builder(
                itemCount: logic.chapters.length,
                itemBuilder: (ctx, index) {
                  return ListTile(
                    onTap: () {
                      Get.toNamed(RouteConfig.getBookRead, arguments: logic.chapters[index]);
                    },
                    title: Text(logic.chapters[index].title ?? ""),
                  );
                },
              );
            },
          )
      ),
    );
  }


}
